home *** CD-ROM | disk | FTP | other *** search
- // main.c
- //
- // part of CIncludesCode MPW tool
- // original version by John Jeppson
- // this tool should normally be called by CIncludesTool MPW Script
-
- #include <PLStringFuncs.h>
- #include <StdIO.h>
- #include <StdLib.h>
- #include <String.h>
- #include "CIncludesCode.h"
-
- Handle database = 0;
- long numFiles;
- dataHeaderType dataHeader;
- Str255 dataFilename;
-
- void CreateDataFileName(void)
- // generate the correct datafile name based on the compiler environment variable
-
- {
- char *pszCompiler = getenv("CIncludesCompiler");
- if (strcmp(pszCompiler,"MetrowerksC++") == 0)
- {
- (void) PLstrcpy(dataFilename,"\p:Preferences:Metrowerks CIncludesData");
- } // if stricmp()
- else
- {
- if (strcmp(pszCompiler,"SymantecC++") == 0)
- {
- (void) PLstrcpy(dataFilename,"\p:Preferences:Symantec CIncludesData");
- } // if stricmp()
- else
- {
- (void) PLstrcpy(dataFilename,"\p:Preferences:Apple CIncludesData");
- } // else if stricmp()
- } // else if stricmp()
- } // CreateDataFileName()
-
- short validateArguments(int argc,char *argv[])
- // terminates tool if bad parameters
-
- {
- switch(argc)
- {
- case 1:
- case 2:
- {
- exit( 1 );
- break;
- } // case 1,2
- case 3:
- {
- if (strcmp(argv[1],"-v") == 0)
- {
- return 2;
- } // if strcpm()
- if (strcmp(argv[1],"-f") == 0)
- {
- return 3;
- } // if strcpm()
- if (strcmp(argv[1],"-i") == 0)
- {
- return 4;
- } // if strcpm()
- if (strcmp(argv[1],"-d") == 0) // Daniel Grassi
- {
- return 5;
- } // if strcpm()
- exit( 1 );
- break;
- } // case 3
- default:
- {
- if (strcmp(argv[1],"-m") == 0)
- {
- return 1;
- } // if strcmp()
- exit( 1 );
- break;
- } // default
- } // switch argc
- } // validateArguments()
-
- int main(int argc,char *argv[])
- {
- char s[64];
- long filePosition;
-
- CreateDataFileName();
- switch(validateArguments(argc,argv))
- {
- case 1: // -m
- {
- return (createDataBase(argc,argv));
- break;
- } // case 1
- case 2: // -v
- {
- return (validate(argv[2]));
- break;
- } // case 2
- case 3: // -f
- {
- if (!loadDatabase())
- {
- return(3);
- } // if !loadDatabase()
- if (locateIdentifier(s,&filePosition,argv[2]))
- {
- (void) printf("#include <%s>\n", s );
- } // if locateIdentifier()
- else
- {
- return(4);
- } // else if locateIdentifier
- break;
- } // case 3
- case 4: // -i
- {
- if (!loadDatabase())
- {
- return(3);
- } // if !loadDatabase()
- return (reformat(argv[2]));
- break;
- } // case 4
- case 5: // -d (Daniel Grassi)
- {
- if (!loadDatabase())
- {
- return(3);
- } // if !loadDatabase()
- if (locateIdentifier(s,&filePosition,argv[2]))
- {
- printf("\"%s\" %d",s,filePosition);
- } // if locateIdentifier()
- else
- {
- return(4);
- } // else if locateIdentifier()
- break;
- } // case 5
- } // switch validateArguments()
- return 0;
- } // main()
-
- // end of main.c